package cn.edu.hyit.hjq.volunteems.backend.controller;

import cn.edu.hyit.hjq.volunteems.backend.dto.reault.JsonResult;
import cn.edu.hyit.hjq.volunteems.backend.dto.request.RegistrationRequest;
import cn.edu.hyit.hjq.volunteems.backend.service.RegistrationService;
import org.springframework.web.bind.annotation.*;

/**
 * 报名控制器
 *
 * @module 报名服务
 */
@RestController
@RequestMapping("/registration")
public class RegistrationController {

    private final RegistrationService registrationService;

    // 构造函数注入 RegistrationService
    public RegistrationController(RegistrationService registrationService) {
        this.registrationService = registrationService;
    }

    /**
     * 报名接口
     * 通过请求体传递报名信息，完成志愿者报名操作
     *
     * @param request 包含报名信息的对象（活动ID、志愿者ID等）
     * @return JsonResult<string> 返回操作结果，成功时返回200
     */
    @PostMapping("/register")
    public JsonResult<?> register(@RequestBody RegistrationRequest request) {
        registrationService.register(request);
        return JsonResult.success("报名成功");
    }
}
